//
//  FrameModel.m
//  rubaoduanzi
//
//  Created by 郝志华 on 16/9/13.
//  Copyright © 2016年 郝志华. All rights reserved.
//

#import "FrameModel.h"

@implementation FrameModel
- (void)setModel:(HotModel *)model{
    _model=model;

    if ([model.photo isEqualToString:@""]&&[model.pic isEqualToString:@""]) {

        //标题
        CGFloat titlex=10;
        CGFloat titley=0;
        CGFloat titlew=[[UIScreen mainScreen] bounds].size.width;
        CGFloat titleh=[self getStrsize:model.content andTextfont:15 andMaxsize:CGSizeMake([[UIScreen mainScreen] bounds].size.width, MAXFLOAT)].height;
        self.biaotiF=CGRectMake(titlex, titley, titlew, titleh);
        //点赞按钮
        CGFloat Zx=10;
        CGFloat Zy=CGRectGetMaxY(self.biaotiF)+20;
        CGFloat Zw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Zh=39;
        self.dianzanF=CGRectMake(Zx, Zy, Zw, Zh);
        //踩按钮
        CGFloat Cx=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Cy=Zy;
        CGFloat Cw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ch=39;
        self.caiF=CGRectMake(Cx, Cy, Cw, Ch);
        //评论按钮
        CGFloat Px=[[UIScreen mainScreen] bounds].size.width/2;
        CGFloat Py=Zy;
        CGFloat Pw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ph=39;
        self.pinlunF=CGRectMake(Px, Py, Pw, Ph);
        //分享按钮
        CGFloat Fx=[[UIScreen mainScreen] bounds].size.width*3/4;
        CGFloat Fy=Zy;
        CGFloat Fw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Fh=39;
        self.fenxF=CGRectMake(Fx, Fy, Fw, Fh);
        self.rowHeight=CGRectGetMaxY(self.dianzanF)+10;

    }else if ([model.photo isEqualToString:@""] &&[model.pic isEqualToString:@""]==NO){
        //标题
        CGFloat titlex=10;
        CGFloat titley=0;
        CGFloat titlew=[[UIScreen mainScreen] bounds].size.width;
        CGFloat titleh=[self getStrsize:model.content andTextfont:15 andMaxsize:CGSizeMake([[UIScreen mainScreen] bounds].size.width, MAXFLOAT)].height+10;
        self.biaotiF=CGRectMake(titlex, titley, titlew, titleh);
        //图片

        CGFloat Ty=CGRectGetMaxY(self.biaotiF);
        CGFloat Tw=[model.width doubleValue];
        CGFloat Th=[model.height doubleValue];
        CGFloat Tx=([[UIScreen mainScreen] bounds].size.width-Tw)/2;
        self.tupianF=CGRectMake(Tx, Ty, Tw, Th);
        //点赞按钮
        CGFloat Zx=10;
        CGFloat Zy=CGRectGetMaxY(self.tupianF)+20;
        CGFloat Zw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Zh=39;
        self.dianzanF=CGRectMake(Zx, Zy, Zw, Zh);
        //踩按钮
        CGFloat Cx=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Cy=Zy;
        CGFloat Cw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ch=39;
        self.caiF=CGRectMake(Cx, Cy, Cw, Ch);
        //品论按钮
        CGFloat Px=[[UIScreen mainScreen] bounds].size.width/2;
        CGFloat Py=Zy;
        CGFloat Pw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ph=39;
        self.pinlunF=CGRectMake(Px, Py, Pw, Ph);
        //分享按钮
        CGFloat Fx=[[UIScreen mainScreen] bounds].size.width*3/4;
        CGFloat Fy=Zy;
        CGFloat Fw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Fh=39;
        self.fenxF=CGRectMake(Fx, Fy, Fw, Fh);
        self.rowHeight=CGRectGetMaxY(self.dianzanF)+10;

    }else if([model.photo isEqualToString:@""]==NO &&[model.pic isEqualToString:@""]){
        //置顶
        CGFloat Dx=0;
        CGFloat Dy=0;
        CGFloat Dw=66;
        CGFloat Dh=66;
        self.zhidingF=CGRectMake(Dx, Dy, Dw, Dh);
        //头像
        CGFloat TXx=10;
        CGFloat TXy=10;
        CGFloat TXw=50;
        CGFloat TXh=50;
        self.touxF=CGRectMake(TXx, TXy, TXw, TXh);
        //昵称
        CGFloat Nx=CGRectGetMaxX(self.touxF);
        CGFloat Ny=TXy;
        CGFloat Nw=100;
        CGFloat Nh=20;
        self.usernameF=CGRectMake(Nx, Ny, Nw, Nh);
        //等级
        CGFloat Lx=CGRectGetMaxX(self.usernameF);
        CGFloat Ly=TXy;
        CGFloat Lw=75;
        CGFloat Lh=30;
        self.dendjiF=CGRectMake(Lx, Ly, Lw, Lh);
        //段位
        CGFloat DWx=CGRectGetMaxX(self.touxF);
        CGFloat DWy=CGRectGetMaxY(self.dendjiF);
        CGFloat DWw=100;
        CGFloat DWh=20;
        self.dunweiF=CGRectMake(DWx, DWy, DWw, DWh);
        //积分
        CGFloat JFx=CGRectGetMaxX(self.dunweiF);
        CGFloat JFy=DWy;
        CGFloat JFw=100;
        CGFloat JFh=20;
        self.jifenF=CGRectMake(JFx, JFy, JFw, JFh);
        //财富
        CGFloat CFx=CGRectGetMaxX(self.jifenF);
        CGFloat CFy=DWy;
        CGFloat CFw=150;
        CGFloat CFh=20;
        self.caifuF=CGRectMake(CFx, CFy, CFw, CFh);
        //标题
        CGFloat Ty=CGRectGetMaxY(self.touxF)+30;
        CGFloat Tx=10;
        CGFloat Tw=[[UIScreen mainScreen] bounds].size.width;
        CGFloat Th=[self getStrsize:model.content andTextfont:15 andMaxsize:CGSizeMake([[UIScreen mainScreen] bounds].size.width, MAXFLOAT)].height+10;
        self.biaotiF=CGRectMake(Tx, Ty, Tw, Th);
        //点赞按钮
        CGFloat Zx=10;
        CGFloat Zy=CGRectGetMaxY(self.biaotiF)+20;
        CGFloat Zw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Zh=39;
        self.dianzanF=CGRectMake(Zx, Zy, Zw, Zh);
        //踩按钮
        CGFloat Cx=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Cy=Zy;
        CGFloat Cw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ch=39;
        self.caiF=CGRectMake(Cx, Cy, Cw, Ch);
        //品论按钮
        CGFloat Px=[[UIScreen mainScreen] bounds].size.width/2;
        CGFloat Py=Zy;
        CGFloat Pw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ph=39;
        self.pinlunF=CGRectMake(Px, Py, Pw, Ph);
        //分享按钮
        CGFloat Fx=[[UIScreen mainScreen] bounds].size.width*3/4;
        CGFloat Fy=Zy;
        CGFloat Fw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Fh=39;
        self.fenxF=CGRectMake(Fx, Fy, Fw, Fh);
        self.rowHeight=CGRectGetMaxY(self.dianzanF)+10;
    }else{
        //置顶
        CGFloat Dx=0;
        CGFloat Dy=0;
        CGFloat Dw=66;
        CGFloat Dh=66;
        self.zhidingF=CGRectMake(Dx, Dy, Dw, Dh);
        //头像
        CGFloat TXx=10;
        CGFloat TXy=10;
        CGFloat TXw=50;
        CGFloat TXh=50;
        self.touxF=CGRectMake(TXx, TXy, TXw, TXh);
        //昵称
        CGFloat Nx=CGRectGetMaxX(self.touxF);
        CGFloat Ny=TXy;
        CGFloat Nw=100;
        CGFloat Nh=20;
        self.usernameF=CGRectMake(Nx, Ny, Nw, Nh);
        //等级
        CGFloat Lx=CGRectGetMaxX(self.usernameF);
        CGFloat Ly=TXy;
        CGFloat Lw=75;
        CGFloat Lh=30;
        self.dendjiF=CGRectMake(Lx, Ly, Lw, Lh);
        //段位
        CGFloat DWx=CGRectGetMaxX(self.touxF);
        CGFloat DWy=CGRectGetMaxY(self.dendjiF);
        CGFloat DWw=100;
        CGFloat DWh=20;
        self.dunweiF=CGRectMake(DWx, DWy, DWw, DWh);
        //积分
        CGFloat JFx=CGRectGetMaxX(self.dunweiF);
        CGFloat JFy=DWy;
        CGFloat JFw=100;
        CGFloat JFh=20;
        self.jifenF=CGRectMake(JFx, JFy, JFw, JFh);
        //财富
        CGFloat CFx=CGRectGetMaxX(self.jifenF);
        CGFloat CFy=DWy;
        CGFloat CFw=100;
        CGFloat CFh=20;
        self.caifuF=CGRectMake(CFx, CFy, CFw, CFh);
        //标题
        CGFloat Ty=CGRectGetMaxY(self.touxF)+30;
        CGFloat Tx=10;
        CGFloat Tw=[[UIScreen mainScreen] bounds].size.width;
        CGFloat Th=[self getStrsize:model.content andTextfont:15 andMaxsize:CGSizeMake([[UIScreen mainScreen] bounds].size.width, MAXFLOAT)].height+10;
        self.biaotiF=CGRectMake(Tx, Ty, Tw, Th);
        //图片

        CGFloat TPy=CGRectGetMaxY(self.biaotiF)+10;
        CGFloat TPw=[model.width doubleValue];
        CGFloat TPh=[model.height doubleValue];
        CGFloat TPx=([[UIScreen mainScreen] bounds].size.width-TPw)/2;
        self.tupianF=CGRectMake(TPx, TPy, TPw, TPh);
        //点赞按钮
        CGFloat Zx=10;
        CGFloat Zy=CGRectGetMaxY(self.tupianF)+20;
        CGFloat Zw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Zh=39;
        self.dianzanF=CGRectMake(Zx, Zy, Zw, Zh);
        //踩按钮
        CGFloat Cx=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Cy=Zy;
        CGFloat Cw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ch=39;
        self.caiF=CGRectMake(Cx, Cy, Cw, Ch);
        //品论按钮
        CGFloat Px=[[UIScreen mainScreen] bounds].size.width/2;
        CGFloat Py=Zy;
        CGFloat Pw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Ph=39;
        self.pinlunF=CGRectMake(Px, Py, Pw, Ph);
        //分享按钮
        CGFloat Fx=[[UIScreen mainScreen] bounds].size.width*3/4;
        CGFloat Fy=Zy;
        CGFloat Fw=[[UIScreen mainScreen] bounds].size.width/4;
        CGFloat Fh=39;
        self.fenxF=CGRectMake(Fx, Fy, Fw, Fh);
        self.rowHeight=CGRectGetMaxY(self.dianzanF)+10;
    }


}
- (CGSize)getStrsize:(NSString *)str andTextfont:(CGFloat )font andMaxsize:(CGSize)maxsize{
    NSMutableDictionary *dict=[NSMutableDictionary dictionary];
    dict[NSFontAttributeName]=[UIFont systemFontOfSize:22];
    CGSize size=CGSizeMake([[UIScreen mainScreen] bounds].size.width-10, MAXFLOAT);
    
   return  [str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size;

}

@end
